#pragma once 

#include <atlbase.h>

#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>

#include <d3d9.h>
#include <d3dx9.h>

#include "debug_util.h"

#define MAX_TEXCOORD_SETS 6

#define D3D_VERIFY(x) { BOOST_ASSERT(SUCCEEDED(x)); }
        
class c_render_device9; 
class c_vertex_buffer9;
class c_index_buffer9; 
class c_texture9;
class c_gpu_program; 
class c_gpu_vertex_program; 
class c_gpu_pixel_program;
class c_d3dx_buffer;
class c_d3dx_mesh;
class c_mesh_entity;
class c_material;
class c_material_parameter_base; 
class c_camera;
class c_frustum;
class c_scene_node;
class c_scene;

typedef boost::shared_ptr<c_render_device9> render_device_ptr;
typedef boost::shared_ptr<c_vertex_buffer9> vertex_buffer_ptr; 
typedef boost::shared_ptr<c_index_buffer9> index_buffer_ptr; 
typedef boost::shared_ptr<c_texture9> texture_ptr; 
typedef boost::shared_ptr<c_gpu_program> gpu_program_ptr;
typedef boost::shared_ptr<c_gpu_vertex_program> gpu_vertex_program_ptr;
typedef boost::shared_ptr<c_gpu_pixel_program> gpu_pixel_program_ptr;
typedef boost::shared_ptr<c_d3dx_mesh> mesh_ptr;
typedef boost::shared_ptr<c_mesh_entity> mesh_entity_ptr; 
typedef boost::shared_ptr<c_material> material_ptr;
typedef boost::shared_ptr<c_material_parameter_base> material_param_ptr;
typedef boost::shared_ptr<c_camera> camera_ptr;
typedef boost::shared_ptr<c_frustum> frustum_ptr;
typedef boost::shared_ptr<c_scene_node> scene_node_ptr;
typedef boost::shared_ptr<c_scene> scene_ptr;

typedef CComPtr<IDirect3D9> d3d9_ptr;
typedef CComPtr<IDirect3DDevice9> d3d9_device_ptr;
typedef CComPtr<IDirect3DTexture9> d3d9_texture_ptr;
typedef CComPtr<IDirect3DVertexBuffer9> d3d9_vb_ptr;
typedef CComPtr<IDirect3DIndexBuffer9> d3d9_ib_ptr;
typedef CComPtr<IDirect3DVertexShader9> d3d9_vs_ptr;
typedef CComPtr<IDirect3DPixelShader9> d3d9_ps_ptr;
typedef CComPtr<IDirect3DVertexDeclaration9> d3d9_verdecl_ptr; 
typedef CComPtr<IDirect3DSurface9> d3d9_surface_ptr;
typedef CComPtr<ID3DXBuffer> d3dx_buffer_ptr;
typedef CComPtr<ID3DXMesh> d3dx_mesh_ptr; 
typedef CComPtr<ID3DXEffect> d3dx_effect_ptr;
typedef CComPtr<ID3DXFont> d3dx_font_ptr;
typedef CComPtr<ID3DXSprite> d3dx_sprite_ptr; 